/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoopp.framework;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Environment;
import android.preference.PreferenceManager;
import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;

public final class a {
    Context a;
    public static final String b = Environment.getExternalStorageDirectory().toString() + "/CrashCatcher/";
    private String e = "http://cl.360pay.cn/upload/do";
    public static String c;
    public static String d = a.c = "ErrorLog";
    private final String f = "errorLogUtil";
    private b g = null;
    private HashMap h = null;
    private c i = null;

    public a(Context paramContext) {
        this.a = paramContext;
    }

    private void d() {
        if (this.g != null)
            return;
        this.g = new b(this, b, d);
    }

    public final void a() {
        if (this.i != null)
            return;
        this.i = new c(this, b);
    }

    public final boolean a(Throwable paramThrowable, HashMap paramHashMap) {
        if (paramThrowable != null) {
            d();
            this.h = paramHashMap;
            StringBuffer localStringBuffer = new StringBuffer();
            StringWriter localStringWriter = new StringWriter();
            PrintWriter localPrintWriter = new PrintWriter(localStringWriter);
            paramThrowable.printStackTrace(localPrintWriter);
            for (paramThrowable = paramThrowable.getCause(); paramThrowable != null; paramThrowable = paramThrowable
                    .getCause())
                paramThrowable.printStackTrace(localPrintWriter);
            localPrintWriter.close();
            paramThrowable = localStringWriter.toString();
            localStringBuffer.append(paramThrowable);
            if (!(this.g.a(localStringBuffer.toString(), paramHashMap))) {
                LogUtil.w("errorLogUtil", "dumpLog, dumpSingleLine failed!");
                return false;
            }
            return true;
        }
        LogUtil.w("errorLogUtil", "dumpLog, ex is null!");
        return false;
    }

    public final boolean a(String paramString, HashMap paramHashMap) {
        if (paramString != null) {
            d();
            this.h = paramHashMap;
            if (!(this.g.a(paramString, paramHashMap))) {
                LogUtil.w("errorLogUtil", "dumpLog, dumpSingleLine failed!");
                return false;
            }
            return true;
        }
        LogUtil.w("errorLogUtil", "dumpLog, ex is null!");
        return false;
    }

    public final int b() {
        Object localObject;
        String str;
        if ((str = (localObject = PreferenceManager.getDefaultSharedPreferences(this.a)).getString("SEND_TIME", "0"))
                .equals("0")) {
            long l = System.currentTimeMillis() / 1000L;
            (localObject = ((SharedPreferences) localObject).edit()).putString("SEND_TIME", Long.toString(l));
            ((SharedPreferences.Editor) localObject).commit();
            return 0;
        }
        return (int) (System.currentTimeMillis() / 1000L - Long.parseLong(str));
    }

    public final boolean a(HashMap paramHashMap) {
        boolean bool = false;
        this.h = paramHashMap;
        try {
            a locala;
            if ((locala = this).i != null) {
                paramHashMap = locala.i;
                for (j = 0; j < paramHashMap.a.length; ++j)
                    if (paramHashMap.a[j] == null) {
                        LogUtil.w("errorLogUtil", "updateFilesInfo, file: " + j + " null.");
                    }
                    else if (!(paramHashMap.a[j].isFile())) {
                        LogUtil.w("errorLogUtil", "updateFilesInfo, file: " + j + " not file.");
                        paramHashMap.a[j] = null;
                    }
                    else {
                        if (paramHashMap.a[j].exists())
                            continue;
                        LogUtil.w("errorLogUtil", "updateFilesInfo, file: " + j + " not exits.");
                        paramHashMap.a[j] = null;
                    }
            }
            paramHashMap = new i();
            int j = 0;
            for (int k = 0; k < this.i.a.length; ++k) {
                if (this.i.a[k] == null)
                    continue;
                ++j;
            }
            LogUtil.w("errorLogUtil", "sendFiles, files num are : " + j);
            d[] arrayOfd = new d[j];
            j = 0;
            for (int l = 0; l < arrayOfd.length; ++l) {
                long l1 = System.currentTimeMillis();
                LogUtil.w("errorLogUtil", "sendFiles, dateTaken is : " + l1);
                while (this.i.a[j] == null)
                    ++j;
                LogUtil.w("errorLogUtil", "sendFiles, file_num is : " + j);
                arrayOfd[l] = new d(this.i.b[j] + l1 + l, this.i.a[j]);
                ++j;
            }
            if (i.a(this.a))
                bool = paramHashMap.a(this.e, this.h, arrayOfd);
        } catch (Exception localException) {
            localException.printStackTrace();
        }
        if (bool)
            LogUtil.w("errorLogUtil", "sendFiles success.");
        else
            LogUtil.w("errorLogUtil", "sendFiles failed.");
        return bool;
    }

    public final boolean c() {
        if (this.i != null) {
            c localc = this.i;
            int j = 1;
            if (localc.a != null) {
                for (int k = 0; k < localc.a.length; ++k)
                    if ((localc.a[k] != null) && (localc.a[k].isFile()) && (localc.a[k].exists())) {
                        LogUtil.w("errorLogUtil", "deleteFiles, file name : " + localc.a[k].getName());
                        localc.a[k].delete();
                    }
                    else {
                        j = 0;
                    }
                if (j == 0)
                    ;
            }
            LogUtil.w("errorLogUtil", "deleteFiles, mFiles == null.");
            return (((LogUtil.w("errorLogUtil", "deleteFiles, failed, not all delete.")) ? 0 : (LogUtil.w(
                    "errorLogUtil", "deleteFiles, success.")) ? 1 : 0) != 0);
        }
        LogUtil.w("errorLogUtil", "deleteFile, mFileManager == null, failed.");
        return false;
    }
}